#define _CRT_SECURE_NO_WARNINGS
class Solution {
public:
    string replaceSpaces(string S, int length) {
        string s1;
        for (int i = 0; i < length; i++) {
            if (S[i] == ' ') {
                s1 += "%20";
            }
            else {
                s1 += S[i];
            }
        }
        return s1;
    }
};